<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@page import="javax.portlet.PortletURL"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@page import="com.animal.bean.Nominee"%>
<%@ include file="/html/animalportlet/init.jsp"%>
<%
	PortletURL viewNomineeURL = renderResponse.createRenderURL();
	viewNomineeURL.setWindowState(LiferayWindowState.EXCLUSIVE);
	viewNomineeURL.setParameter("jspPage",
			"/html/animalportlet/details.jsp");
	viewNomineeURL.setParameter("showHeader", "false");
	PortletURL voteURL = renderResponse.createRenderURL();
	voteURL.setWindowState(LiferayWindowState.EXCLUSIVE);
	voteURL.setParameter("jspPage", "/html/animalportlet/vote.jsp");
	
	PortletURL iteratorURL = renderResponse.createRenderURL();
	iteratorURL.setParameter("jspPage", "/html/animalportlet/view.jsp");


	List<Nominee> lists = new ArrayList<Nominee>();
	lists.add(new Nominee("AK", "Friends of Pets", "Anchorage"));
	lists.add(new Nominee("AL", "Prattville/Autauga Humane Society",
			"Prattville"));
	lists.add(new Nominee("AR", "Wynne Friends of Animals", "Wynne"));
	lists.add(new Nominee("AZ", "Humane Society of Southern Arizona",
			"Tucson"));
	lists.add(new Nominee("CA", "Medfly Brigade Basenji Rescue",
			"Acton"));
	lists.add(new Nominee("CO", "National Mill Dog Rescue",
			"Colorado Springs"));
	lists.add(new Nominee("CT", "Meriden Humane Societyg", "Meriden"));
	lists.add(new Nominee("DC", "Lucky Dog Animal Rescue", "Washington"));
	lists.add(new Nominee("DE", "Forgotten Cats Inc.", "Claymont"));
	lists.add(new Nominee("FL", "Pet Rescue by Judy", "Sanford"));
	lists.add(new Nominee("GA", "Angels Among Us Pet Rescue, Inc.",
			"Alpharetta"));
	lists.add(new Nominee("HI", "9th Life Hawaii", "Makawao"));
	lists.add(new Nominee("IA",
			"Harrison County Humane Society of Iowa", "Logan"));
	lists.add(new Nominee("ID", "Boise Bully Breed Rescue", "Boise"));
%>

<html>
<head>
<script type="text/javascript"
	src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js">
	
</script>
</head>
<body>

	<p
		style="font-size: medium; font-weight: bold; font-style: normal; font-color: blue">The
		List Of Nominees</p>

	<liferay-ui:search-container delta="5" iteratorURL="<%=iteratorURL %>">
		<liferay-ui:search-container-results
			results="<%= ListUtil.subList(lists,searchContainer.getStart(),searchContainer.getEnd()) %>"
			total="<%=lists.size()%>" />

		<liferay-ui:search-container-row className="com.animal.bean.Nominee"
			modelVar="aNominee">
			<%
                 	String nomineeId = aNominee.getNomineeId();
                 			String name = aNominee.getName();
                 			String location = aNominee.getLocation();
                 			viewNomineeURL.setParameter("nominee_Id", nomineeId);
                 			viewNomineeURL.setParameter("nominee_name", name);
                 			viewNomineeURL.setParameter("nominee_location", location);
                 			String popup = "javascript:popup('"
                 					+ viewNomineeURL.toString() + "');";
                 			voteURL.setParameter("nominee_name", name);
                 			String votePopup = "javascript:votePopup('"
                 					+ voteURL.toString() + "');";
                 %>

			<liferay-ui:search-container-column-text name="NomineeId">
				<a href="#" onclick="javascript:description('description');"><%=aNominee.getNomineeId()%></a>
			</liferay-ui:search-container-column-text>


			<liferay-ui:search-container-column-text name="Nominee Name">
				<a href="#" onclick="<%=popup%>"><%=aNominee.getName()%></a>
			</liferay-ui:search-container-column-text>

			<liferay-ui:search-container-column-text property="location" />


			<liferay-ui:search-container-column-text name="Action">

				<button id="<%=aNominee.getName()%>"
					onClick="<%=votePopup%>;javascript:change(this,'<%=aNominee.getName()%>');">vote</button>
			</liferay-ui:search-container-column-text>
		</liferay-ui:search-container-row>

		<liferay-ui:search-iterator searchContainer="<%=searchContainer %>" />
	</liferay-ui:search-container>


	<%-- </liferay-ui:panel>
	</liferay-ui:panel-container> --%>
	<div id="description"
		style="display: none; font-family: inherit; font-variant: normal; font-size: small;">
		<img src="<%= request.getContextPath()%>/images/desc1.jpg" height="50"
			width="50" align="left">I went to a local no kill shelter
		looking for a cat to adopt. I'd always had animals around growing up
		and missed having onearound as I began my new job in Hartford, CT. The
		room was full and I had no way to choose. I simply sat on the floor to
		see what happened. This gray tabby with the BIG green eyes jumped in
		my lap and started to purr. The caretaker said This is Jonathan. He is
		going to be our featured cat in the next newsletter
	</div>

</body>
</html>


<script type="text/javascript">
	
	function change(button,name){
		if (themeDisplay.isSignedIn()) {
		document.getElementById(name).innerHTML = "Thanks for voting";
		button.disabled = true;
		}
	}
	function description(description){
		document.getElementById(description).style.display='block';
	}
	function popup(url){
		
		AUI().use('aui-dialog', 'aui-io', function(A) {
		
		    var dialog = new A.Dialog({
		    title: 'Nominee Details',
		    centered: true,
		    modal: true,
		    width: 300,
		    height: 150,
		    }).plug(A.Plugin.IO, {uri: url}).render();
		
		});
	}
	
	function votePopup(url){
		
		AUI().use('aui-dialog', 'aui-io', function(A) {
		
		    var dialog = new A.Dialog({
		    title: ' ',
		    centered: true,
		    modal: true,
		    width: 300,
		    height: 150,
		    }).plug(A.Plugin.IO, {uri: url}).render();
		
		});
		
	}

	 /* $('#btn').click(function(){
		$('#btn').attr("disabled", true);	
	});
	 */ 
</script>






